package me.sealer.java8.actparamterized.utils;

import me.sealer.java8.actparamterized.predicate.CustomPredicate;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by sealer on 09-17-2017.
 */
public class FilterUtil {
    /**
     * filter筛选
     */
    public static <T> List<T> filter(List<T> list, CustomPredicate<T> customPredicate) {
        List<T> result = new ArrayList<>();
        for (T t : list) {
            if (customPredicate.test(t)) {
                result.add(t);
            }
        }
        return result;
    }
}
